<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extra/spring-security">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="icon" type="shortcut icon" th:href="@{/img/favicon.ico}" />
    <link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap.min.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/css/global.css}" />
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css">
    <title>郑在守护—智防通</title>
    <style>
        /* 防诈骗横幅样式 */
        .anti-fraud-banner {
            background: rgb(18, 127, 249);
            color: white;
            padding: 8px;
            text-align: center;
            font-size: 0.9rem;
        }
        
        .anti-fraud-banner h4 {
            font-size: 1rem;
            margin-bottom: 4px;
        }
        
        .anti-fraud-banner p {
            font-size: 0.8rem;
            margin-bottom: 0;
        }
        
        /* 确保header不是深色背景 */
        header.bg-dark {
            background-color: white !important;
        }
        
        /* 直接复制index.html的导航栏样式 */
        .navbar {
            background-color: white !important;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            height: 56px;
            padding: 0;
            border-radius: 4px;
            margin-top: 5px;
        }
        
        .navbar-brand {
            display: flex;
            align-items: center;
            padding: 0 16px;
            height: 56px;
            border-right: 1px solid #f0f0f0;
            font-weight: 600;
            color: #2196F3;
            transition: all 0.3s ease;
        }
        
        .navbar-brand:hover {
            background-color: rgba(33, 150, 243, 0.05);
        }
        
        .navbar-brand i {
            color: #2196F3;
            font-size: 20px;
            margin-right: 8px;
        }
        
        .navbar-brand span {
            color: #2196F3;
            font-size: 16px;
            font-weight: 600;
        }
        
        .navbar-nav {
            display: flex;
            align-items: center;
            height: 56px;
            padding: 0 12px;
        }
        
        .nav-item {
            height: 56px;
            margin: 0 2px;
        }
        
        .nav-link {
            display: flex !important;
            align-items: center;
            height: 56px;
            padding: 0 12px !important;
            color: #666 !important;
            position: relative;
            font-size: 13px;
            transition: all 0.3s ease;
        }
        
        .nav-link i {
            font-size: 16px;
            margin-right: 5px;
            transition: transform 0.2s ease;
            display: inline-block;
            vertical-align: middle;
        }
        
        .nav-link span {
            display: inline-block;
            vertical-align: middle;
        }
        
        .nav-link:hover {
            color: #2196F3 !important;
            background-color: rgba(33, 150, 243, 0.05);
        }
        
        .nav-link:hover i {
            transform: scale(1.1);
        }
        
        .nav-link.active {
            color: #2196F3 !important;
            font-weight: 500;
        }
        
        .nav-link.active:after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 16px;
            right: 16px;
            height: 2px;
            background-color: #2196F3;
        }
        
        /* 修改通知徽章样式，使其成为红色圆圈白色数字 */
        .badge-danger {
            position: absolute;
            top: -5px;
            right: -5px;
            padding: 0.25rem 0.4rem;
            font-size: 0.75rem;
            font-weight: 700;
            color: #fff;
            background-color: #ff4d4f;
            border-radius: 50%;
            min-width: 18px;
            height: 18px;
            line-height: 1;
            text-align: center;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 0 0 1px #fff;
        }
        
        /* 为导航项添加相对定位，以便正确放置通知徽章 */
        .nav-link.position-relative {
            position: relative;
        }
        
        .search-form {
            position: relative;
            margin-right: 12px;
        }
        
        .search-form input {
            width: 200px;
            height: 32px;
            padding: 0 32px 0 12px;
            border: 1px solid #e8e8e8;
            border-radius: 16px;
            background-color: #f5f5f5;
            font-size: 13px;
            transition: all 0.3s ease;
        }
        
        .search-form input:focus {
            width: 240px;
            border-color: #2196F3;
            box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
            outline: none;
        }
        
        .search-form .serach-btn {
            position: absolute;
            right: 4px;
            top: 4px;
            width: 24px;
            height: 24px;
            font-size: 14px;
            background-color: transparent;
            border: none;
            color: #2196F3;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        
        .search-form .serach-btn:hover {
            transform: scale(1.1);
            color: #1976D2;
        }
        
        .user-info {
            height: 56px;
            border-left: 1px solid #f0f0f0;
            padding-left: 16px;
            transition: all 0.3s ease;
        }
        
        .user-info:hover {
            background-color: rgba(33, 150, 243, 0.05);
        }
        
        .user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            margin-right: 6px;
            border: 2px solid rgba(33, 150, 243, 0.2);
            transition: all 0.3s ease;
        }
        
        .user-info:hover .user-avatar {
            border-color: rgba(33, 150, 243, 0.5);
        }
        
        /* 确保导航栏水平显示 */
        .navbar-nav.mr-auto {
            flex-wrap: nowrap;
            overflow-x: visible;
            width: auto;
            margin-right: 0 !important;
        }
        
        /* 确保导航栏容器宽度合适 */
        .navbar > .container {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 10px;
            max-width: 100%;
        }
        
        /* 调整折叠导航栏 */
        .collapse.navbar-collapse {
            display: flex !important;
            flex-basis: auto;
            justify-content: space-between;
        }
        
        /* 确保导航项目在一行显示 */
        .navbar-nav {
            flex-direction: row !important;
            flex-wrap: nowrap !important;
        }
        
        /* 调整导航项目间距 */
        .navbar-nav .nav-item {
            white-space: nowrap;
            margin: 0 2px;
        }
        
        /* 调整搜索框和用户信息的位置 */
        .navbar-right {
            display: flex;
            align-items: center;
            margin-left: auto;
        }
        
        /* 添加额外的样式确保导航栏在一行显示 */
        @media (min-width: 992px) {
            .navbar-expand-lg .navbar-nav {
                flex-direction: row;
            }
            
            .navbar-expand-lg .navbar-collapse {
                display: flex !important;
                flex-basis: auto;
            }
        }
        
        /* 防诈骗内容样式 */
        .anti-fraud-content {
            position: fixed;
            right: 0;
            width: 280px;
            padding: 15px;
            background-color: #fff;
            box-shadow: -2px 0 4px rgba(0,0,0,0.05);
            z-index: 100;
        }
        
        .anti-fraud-tip {
            background-color: #fff3cd;
            border: 1px solid #ffeeba;
            padding: 8px;
            margin-bottom: 10px;
            border-radius: 4px;
            font-size: 0.85rem;
        }
        
        .anti-fraud-tip h5 {
            font-size: 0.9rem;
            margin-bottom: 6px;
        }
        
        .anti-fraud-tip ul {
            padding-left: 16px;
            margin-bottom: 0;
        }
        
        .anti-fraud-tip li {
            font-size: 0.8rem;
            line-height: 1.4;
            margin-bottom: 4px;
        }
        
        .emergency-contact {
            background-color: #dc3545;
            color: white;
            padding: 8px;
            border-radius: 4px;
            text-align: center;
            font-size: 0.85rem;
        }
        
        .emergency-contact h5 {
            font-size: 0.9rem;
            margin-bottom: 4px;
        }
        
        /* 主内容区域调整 */
        .main-content {
            margin-right: 300px; /* 为防诈骗侧边栏留出空间 */
            margin-left: 80px; /* 为左侧二维码留出空间 */
        }
    </style>
</head>
<body>
<div class="nk-container">
    <!-- 防诈骗横幅 -->
    <div class="anti-fraud-banner">
        <div class="container">
            <h4><i class="bi bi-shield-check"></i> 提高警惕，防范诈骗</h4>
            <p class="mb-0">共建平安校园，远离电信诈骗</p>
        </div>
    </div>
    
    <!-- 头部 -->
    <header class="bg-white sticky-top" th:replace="index::header">
    </header>

    <!-- 内容 -->
    <div class="main">
        <div class="container">
            <!-- 防诈骗提示侧边栏 -->
            <div class="anti-fraud-content">
                <div class="anti-fraud-banner">
                    <h4><i class="bi bi-shield-exclamation"></i> 防诈骗警示</h4>
                    <p>共同守护财产安全，远离电信网络诈骗</p>
                </div>
                <div class="anti-fraud-tip">
                    <h5>防诈骗小贴士</h5>
                    <ul class="mb-0">
                        <li><i class="bi bi-check2"></i> 不轻信陌生来电，不透露个人信息</li>
                        <li><i class="bi bi-check2"></i> 不随意点击不明链接</li>
                        <li><i class="bi bi-check2"></i> 遇到可疑情况及时报警</li>
                    </ul>
                </div>
                <div class="emergency-contact">
                    <h5>紧急联系方式</h5>
                    <p>全国反诈中心热线：96110</p>
                </div>
            </div>
            <div class="position-relative">
                <!-- 新增案例按钮 - 仅在用户登录时显示 -->
                <div class="mb-3" th:if="${loginUser != null}">
                    <a th:href="@{/fraud/publish}" class="btn btn-primary">
                        <i class="bi bi-plus-circle"></i> 新增案例
                    </a>
                </div>
                <!-- 筛选 -->
                <ul class="nav nav-tabs mb-3">
                    <li class="nav-item">
                        <a class="nav-link" th:classappend="${currentType == null ? 'active' : ''}" th:href="@{/fraud/list}">全部</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:classappend="${currentType == '电信诈骗' ? 'active' : ''}" th:href="@{/fraud/type(type='电信诈骗')}">电信诈骗</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:classappend="${currentType == '网络诈骗' ? 'active' : ''}" th:href="@{/fraud/type(type='网络诈骗')}">网络诈骗</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:classappend="${currentType == '金融诈骗' ? 'active' : ''}" th:href="@{/fraud/type(type='金融诈骗')}">金融诈骗</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:classappend="${currentType == '投资诈骗' ? 'active' : ''}" th:href="@{/fraud/type(type='投资诈骗')}">投资诈骗</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:classappend="${currentType == '冒充熟人' ? 'active' : ''}" th:href="@{/fraud/type(type='冒充熟人')}">冒充熟人</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:classappend="${currentType == '其他' ? 'active' : ''}" th:href="@{/fraud/type(type='其他')}">其他</a>
                    </li>
                </ul>
                <!-- 案例列表 -->
                <ul class="list-unstyled">
                    <li class="media pb-3 pt-3 mb-3 border-bottom" th:each="fraudCase:${fraudCases}">
                        <div class="media-body">
                            <h6 class="mt-0 mb-3">
                                <a th:href="@{|/fraud/detail/${fraudCase.id}|}" th:utext="${fraudCase.title}">案例标题</a>
                                <span class="badge badge-secondary bg-primary" th:if="${fraudCase.status==1}">置顶</span>
                            </h6>
                            <div class="text-muted font-size-12">
                                <span>类型: <i th:text="${fraudCase.type}">类型</i></span> &nbsp;&nbsp;
                                <span>发布时间: <i th:text="${#dates.format(fraudCase.createTime,'yyyy-MM-dd HH:mm:ss')}">2019-04-28 14:13:25</i></span>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </div>

    <!-- 尾部 -->
    <footer class="bg-dark" th:replace="index::footer">
    </footer>
</div>

<!-- 添加与index.html一致的页脚样式 -->
<style>
    /* 页脚样式优化 */
    footer.bg-dark {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 60px;
        background-color: rgba(52, 58, 64, 0.95) !important;
        padding: 10px 0;
        z-index: 1000;
    }
    
    .qrcode-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    
    .qrcode-container img {
        width: 50px !important;
        height: 50px !important;
        margin-bottom: 2px;
    }
    
    .qrcode-container p {
        margin: 0;
        font-size: 0.7rem;
        color: rgba(255, 255, 255, 0.8);
    }
    
    .company-info {
        font-size: 0.8rem;
        margin: 0;
        padding: 0;
    }
    
    .company-info li {
        margin-bottom: 2px;
        color: rgba(255, 255, 255, 0.8) !important;
    }
    
    /* 主内容区域调整，为固定定位的页脚留出空间 */
    .main {
        padding-bottom: calc(16.67vh + 20px);
    }
    
    /* 防止内容被页脚遮挡 */
    .nk-container {
        min-height: 100vh;
        position: relative;
        padding-bottom: 16.67vh;
    }
</style>

<script type="text/javascript" th:src="@{/js/jquery-3.6.0.min.js}"></script>
<script type="text/javascript" th:src="@{/js/popper.min.js}"></script>
<script type="text/javascript" th:src="@{/js/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{/js/global.js}"></script>

<!-- 新增案例模态框 -->
<div class="modal fade" id="addFraudCaseModal" tabindex="-1" role="dialog" aria-labelledby="addFraudCaseModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="addFraudCaseModalLabel">新增诈骗案例</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form id="addFraudCaseForm">
                    <div class="form-group">
                        <label for="title">标题</label>
                        <input type="text" class="form-control" id="title" name="title" required>
                    </div>
                    <div class="form-group">
                        <label for="type">类型</label>
                        <select class="form-control" id="type" name="type" required>
                            <option value="电信诈骗">电信诈骗</option>
                            <option value="网络诈骗">网络诈骗</option>
                            <option value="金融诈骗">金融诈骗</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="content">内容</label>
                        <textarea class="form-control" id="content" name="content" rows="5" required></textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="submitFraudCase()">提交</button>
            </div>
        </div>
    </div>
</div>

<script>
function submitFraudCase() {
    var formData = {
        title: $("#title").val(),
        type: $("#type").val(),
        content: $("#content").val()
    };

    $.ajax({
        url: '/fraud/add',
        type: 'POST',
        contentType: 'application/json',
        data: JSON.stringify(formData),
        success: function(response) {
            if(response.code === 200) {
                alert("添加成功！");
                window.location.reload();
            } else {
                alert(response.msg || "添加失败，请重试！");
            }
        },
        error: function() {
            alert("添加失败，请重试！");
        }
    });
}
</script>
</body>
</html>